<%--
  Created by IntelliJ IDEA.
  User: 11576
  Date: 2022/12/29
  Time: 12:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>添加品牌</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="css/style.css"/>
    <link rel="stylesheet" href="assets/css/ace.min.css" />
    <link rel="stylesheet" href="assets/css/font-awesome.min.css" />
    <link href="Widget/icheck/icheck.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    <script src="assets/js/typeahead-bs2.min.js"></script>
    <script src="assets/layer/layer.js" type="text/javascript"></script>
    <script type="text/javascript" src="Widget/swfupload/swfupload.js"></script>
    <script type="text/javascript" src="Widget/swfupload/swfupload.queue.js"></script>
    <script type="text/javascript" src="Widget/swfupload/swfupload.speed.js"></script>
    <script type="text/javascript" src="Widget/swfupload/handlers.js"></script>
</head>

<body>
<div class=" clearfix">
    <form action="${pageContext.request.contextPath}/back/editBrand" method="post" enctype="multipart/form-data"><%--做文件上传必须用enctype--%>
    <div id="add_brand" class="clearfix">
        <div class="left_add" style="width: 100%;">
            <div class="title_name" style="width: 100%;">修改品牌</div>
            <ul class="add_conent">
                <li class=" clearfix">
                    <label class="label_name"><i>*</i>品牌序号：</label>
                    <input name="brand_id" type="text" class="add_text" style="width:600px" value="${brand.brand_id}" readonly/>
                </li>
                <li class=" clearfix">
                    <label class="label_name"><i>*</i>品牌名称：</label>
                    <input name="brand_name" type="text" class="add_text" style="width:600px" value="${brand.brand_name}"/>
                </li>
                <li class=" clearfix">
                    <label class="label_name"><i>*</i>品牌图片：</label>
                    <input onchange="uploadImg()" id="brand_logo" name="brand_logo" type="file" class="add_text" multiple="multiple" style="width:600px"/>
                    <img src="${brand.brand_logo}" id="review">
                    <script type="text/javascript">
                        function uploadImg(){
                            var file=$("#brand_logo")[0].files[0];
                            /*console.log(file);*/
                            var formData=new FormData();
                            formData.append("brand_logo",file);
                            $.ajax({
                                type: "post",
                                url:getPageContext()+"/back/brandImgUpload",
                                data: formData,
                                processData:false,/*数据非压缩类型*/
                                contentType:false,/*没有类型，则以流的方式传输*/
                                success:function (json){
                                    if (json.code==1000){
                                        $("#review").attr("src",getPageContext()+json.msg);
                                        $("#review").attr("height","80px");
                                    }
                                }
                            })
                        }

                        function getPageContext() {
                            //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
                            var curWwwPath = window.document.location.href;
                            //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
                            var pathName = window.document.location.pathname;
                            var pos = curWwwPath.indexOf(pathName);
                            //获取主机地址，如： http://localhost:8083
                            var localhostPaht = curWwwPath.substring(0, pos);
                            //获取带"/"的项目名，如：/uimcardprj
                            var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
                            // 打印获取当前项目根路径
                            return (localhostPaht + projectName);
                        }
                    </script>
                </li>
                <li class=" clearfix">
                    <label class="label_name"><i>*</i>品牌描述：</label>
                    <textarea name="brand_desc" cols="" rows="" value="${brand.brand_desc}" class="textarea" style="width:600px" onkeyup="checkLength(this);"></textarea>
                    <span class="wordage">剩余字数：<span id="sy" style="color:Red;">500</span>字</span>
                </li>
                <li class=" clearfix">
                    <label class="label_name"><i>*</i>显示状态：</label>
                    <label><input name="brand_status" value="1" type="radio" class="ace" checked="checked"><span class="lbl">显示</span></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <label><input type="radio" class="ace" value="0"  name="brand_status"><span class="lbl">不显示</span></label>
                </li>
            </ul>
        </div>
        <div class="button_brand">
            <input type="submit"  class="btn btn-warning" value="保存"/>
<%--            <input name="" type="reset" value="取消" class="btn btn-warning"/>--%>
            <button class="btn btn-warning" id="qx" onclick="qx()">取消</button>
        </div>
    </div>
    </form>
</div>
</body>
</html>
<script type="text/javascript">
    function qx(){
    }

    $(document).ready(function(){
        $(".left_add").height($(window).height()-60);
        $(".select").height($(window).height()-195);
        $("#select_style").height($(window).height()-220);
        //当文档窗口发生改变时 触发
        $(window).resize(function(){
            $(".left_add").height($(window).height()-60);
            $(".select").height($(window).height()-195);
            $("#select_style").height($(window).height()-220);
        });
    })
    function checkLength(which) {
        var maxChars = 500;
        if(which.value.length > maxChars){
            layer.open({
                icon:2,
                title:'提示框',
                content:'您出入的字数超多限制!',
            });
            // 超过限制的字数了就将 文本框中的内容按规定的字数 截取
            which.value = which.value.substring(0,maxChars);
            return false;
        }else{
            var curr = maxChars - which.value.length; // 减去 当前输入的
            document.getElementById("sy").innerHTML = curr.toString();
            return true;
        }

    }


</script>
